//
//  HTTPRequestManager.h
//  ZhaoQiPei
//
//  Created by 找汽配ios开发 on 15/11/28.
//  Copyright © 2015年 祥运. All rights reserved.
//

#import <Foundation/Foundation.h>
#import "XYEnum.h"

@class MBProgressHUD;

@interface HTTPRequest : NSObject

@property (nonatomic, weak) NSURLSessionDataTask * task;
@property (nonatomic, assign) BOOL progress;
@property (nonatomic, copy) void(^success)(id responseObject);
@property (nonatomic, copy) void(^warn)(NSString * content);
@property (nonatomic, copy) void(^invalid)();
@property (nonatomic, copy) void(^cancel)();
@property (nonatomic, copy) void(^timeout)();
@property (nonatomic, copy) void(^offline)();
@property (nonatomic, copy) void(^error)(ErrorCode errorCode, NSString * content);
@property (nonatomic, copy) void(^failure)(NSError * error);
@property (nonatomic, copy) void(^completion)(BOOL success);

+ (instancetype)request;

- (void)GET:(NSString *)URLString parameters:(id)parameters;
- (void)POST:(NSString *)URLString parameters:(id)parameters;
- (void)dataGET:(NSString *)URLString parameters:(id)parameters;
- (NSURLSessionUploadTask *)uploadWithRequest:(NSURLRequest *)request data:(NSData *)data progress:(void(^)(NSProgress * uploadProgress))progress;

@end
